home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_05 / xmpl_03.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  419 b   |  21 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 5, example 3
  5.  
  6. function factorial n -> 
  7.     if n <= 0 then return 1 
  8.     else return (n * (factorial (n - 1)))
  9. -- now, try a few test values
  10. factorial 0
  11. factorial 4
  12.  
  13. function sumAndPrint #rest args -> (
  14.     local mysum:0
  15.     for i in args do mysum := mysum + i
  16.     format debug "The sum is: %*\n" mysum @normal
  17.     return mysum
  18. )
  19.  
  20. sumAndPrint 10 20 34 45
  21. -->>>